package projectOne;

import projectOne.service.CallService;
import projectOne.service.NetService;
import projectOne.service.SendService;

public class MobileCard {
    private String cardNumber;
    private ServicePackage servicePackage;
    private double money;
    private double consumAmount;//消费金额
    private int realTalkTime;//实际通话时间
    private int realSMSCount;//实际短信条数
    private int realFlow;//实际上网流量

    public void show(){
        System.out.println("卡号："+cardNumber+"\t余额："+money+"\t消费金额："+consumAmount);
        System.out.println("已通话时长："+realTalkTime+"分钟"+"\t已发送短信："+realSMSCount+"条"+"\t消耗流量："+realFlow+"M");
        System.out.println("=======套餐======");
        System.out.println(servicePackage.toString());
    }
    //发送短信
    public void send(int count){
        if (servicePackage instanceof SendService){
            SendService sendService=(SendService) servicePackage;
            sendService.send(count,this);
        }
    }
    //通话
    public void call(int time){
        if (servicePackage instanceof SendService){
            CallService callService=(CallService) servicePackage;
            callService.call(time,this);
        }
    }
    //上网
    public void net(int flow){
        if (servicePackage instanceof SendService){
            NetService netService=(NetService) servicePackage;
            netService.net(flow,this);
        }
    }
    //构造方法
    public MobileCard(String cardNumber, ServicePackage servicePackage, double money) {
        this.cardNumber = cardNumber;
        this.servicePackage = servicePackage;
        this.money = money;
    }

    public String getCardNumber() {
        return cardNumber;
    }

    public ServicePackage getServicePackage() {
        return servicePackage;
    }

    public void setServicePackage(ServicePackage servicePackage) {
        this.servicePackage = servicePackage;
    }

    public void setCardNumber(String cardNumber) {
        this.cardNumber = cardNumber;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public double getConsumAmount() {
        return consumAmount;
    }

    public void setConsumAmount(double consumAmount) {
        this.consumAmount = consumAmount;
    }

    public int getRealTalkTime() {
        return realTalkTime;
    }

    public void setRealTalkTime(int realTalkTime) {
        this.realTalkTime = realTalkTime;
    }

    public int getRealSMSCount() {
        return realSMSCount;
    }

    public void setRealSMSCount(int realSMSCount) {
        this.realSMSCount = realSMSCount;
    }

    public int getRealFlow() {
        return realFlow;
    }

    public void setRealFlow(int realFlow) {
        this.realFlow = realFlow;
    }
}
